<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>snakeAdmin-登录</title>
    <link rel="stylesheet" href="__STATIC__/index/layui/css/layui.css">
</head>
<style type="text/css" media="screen">
    .login-box{
        position: absolute;
        width: 400px;
        top: 50%;
        left: 50%;
        margin-left: -200px;
        margin-top: -200px;

        -moz-box-shadow: 10px 5px 10px 5px #888888; /* 老的 Firefox */
        box-shadow: 10px 5px 10px 5px #888888;
    }
</style>
<body>
   
    <div class="login-box">
         <div class="layui-card-body">
          <blockquote class="layui-elem-quote">电商之家管理系统</blockquote>
        </div>

        <div class="layui-card layui-anim-upbit">
            <!-- <div class="layui-card-header">
                电商之家·系统后台
            </div> -->
            <div class="layui-form">
            <div class="layui-card-body layui-row layui-col-space10">
                <div class="layui-form-item">
                    <input type="text" name="user_name" placeholder="请输入帐号" lay-verify="required" autocomplete="off" class="layui-input">
                </div>
                <div class="layui-form-item">
                    <input type="password" name="password" placeholder="请输入密码" lay-verify="pass" autocomplete="off" class="layui-input">
                </div>
                <div class="layui-form-item">
                    <div class="layui-col-md5">
                        <input type="text" name="code" placeholder="验证码" lay-verify="required" autocomplete="off" class="layui-input">
                    </div>
                    <div class="layui-col-md5 layui-col-md-offset1">
                        <img id="verify" src="{:url('Login/vertify')}" alt="" width="120px">
                    </div>
                </div>

                <div class="layui-form-item layui-col-md12" style="margin-bottom: 20px">
                    <div class="layui-btn-container">
                        <button  class="layui-btn layui-btn-fluid" lay-submit lay-filter="*">登陆</button>
                    </div>
                </div>
            </div>
            </div>
        </div>
    </div>
    <script type="text/javascript" src="__STATIC__/index/layui/layui.js"></script>
    <script>
        layui.use(['layer', 'form', 'jquery'],function(){
            var layer = layui.layer; 
            var form = layui.form;
            var $ = layui.jquery;

            document.onkeydown = function(e){
                var ev = document.all ? window.event : e;
                if(ev.keyCode==13) {
                   $('.layui-btn').click();
                }
            }

            form.on('submit(*)', function(data){
                $.post("{:url('login/doLogin')}",data.field,function(data){
                    if(data.code!=1){
                        $('#verify').attr('src', '{:url('vertify')}?tm='+Math.random());
                        $('input[name=code]').val('');
                        layer.msg(data.msg);
                        return;
                    }else{
                        window.location.href=data.data;
                    }
                });
             return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
            });

            $('#verify').on('click', function(event) {
                event.preventDefault();
                $('#verify').attr('src', "{:url('vertify')}?tm="+Math.random());
            });
                
        });



        
      
    </script>
</body>
</html>